package cn.itcast.bos.service.staff;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Projections;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.staff.IStaffDao;
import cn.itcast.bos.domain.PageBean;
import cn.itcast.bos.domain.Staff;

@Service
@Transactional
public class StaffServiceImpl implements IStaffService {

	@Resource
	private IStaffDao staffDao;

	@Override
	public void save(Staff model) {
		staffDao.save(model);
	}

	@Override
	public void pageQuery(PageBean pageBean) {
		staffDao.pageQuery(pageBean);
	}

	@Override
	public void delete(String ids) {
		  String[] split = ids.split(",");
		for (int i = 0; i < split.length; i++) {
			Staff staff = staffDao.findOne(split[i]);
			staff.setDeltag("1");
		}
	}

	@Override
	public void restore(String ids) {
		 String[] split = ids.split(",");
			for (int i = 0; i < split.length; i++) {
				Staff staff = staffDao.findOne(split[i]);
				staff.setDeltag("0");
	    }
	}

	@Override
	public void update(Staff staff) {
		staffDao.update(staff);
	}

	@Override
	public Staff findOne(String id) {
		return staffDao.findOne(id);
	}

	@Override
	public List<Staff> findByCondition(DetachedCriteria dc) {
		return staffDao.findByCriteria(dc);
	}
}
